{extend name="light-year/layout/default" /}

{block name="title"}管理员登录日志管理{/block}

{block name="content"}
<div class="card-toolbar clearfix">
    <div class="toolbar-btn-action">
        <a class="btn btn-danger" href="javascript:;" onclick="batchDelOperation('{:url(\'delete\')}');">
            <i class="mdi mdi-window-close"></i> 批量删除
        </a>
        <a class="btn btn-info m-r-5" href="javascript:;" onclick="batchExport('{:url(\'export\')}');"><i class="mdi mdi-export"></i> 导出 </a>
    </div>
    <hr>
    <form class="form-inline first_form" action="" method="get">
        <div class="form-group">
            <?php $search_month = input('search_month', date('Y-m')); ?>
            <select name="search_month" class="form-control">
                <option value="{date('Y-m')}" {$search_month == date('Y-m') ? 'selected' : ''}> 请选择指定月份的日志 </option>
                {if !empty($all_monthes)}
                    {foreach $all_monthes as $month}
                        <option value="{$month}" {$search_month == $month ? 'selected' : ''}> {$month} 的日志 </option>
                    {/foreach}
                {/if}
            </select>
        </div>
        <div class="form-group">
            <?php $log_status = input('log_status', -1); ?>
            <select name="log_status" class="form-control">
                <option value="-1" {$log_status == -1 ? 'selected' : ''}> 请选择登录状态 </option>
                <option value="1" {$log_status == 1 ? 'selected' : ''}> 成功 </option>
                <option value="0" {$log_status == 0 ? 'selected' : ''}> 失败 </option>
            </select>
        </div>
        <div class="form-group">
            <?php $admin_id = input('admin_id', -1); ?>
            <select name="admin_id" class="form-control">
                <option value="-1" {$admin_id == -1 ? 'selected' : ''}> 请选择管理员 </option>
                {if !empty($admins)}
                {foreach $admins as $admin}
                <option value="{$admin->admin_id}" {$admin_id == $admin->admin_id ? 'selected' : ''}> {$admin->admin_name} </option>
                {/foreach}
                {/if}
                <option value="0" {$admin_id == 0 ? 'selected' : ''}> 其它（账户错误，未获取到管理员）</option>
            </select>
        </div>
        <a class="btn btn-default" onclick="$('form').submit();"><i class="mdi mdi-magnify"></i> 搜索 </a>
        <a class="btn btn-warning" href="{:url()}"><i class="mdi mdi-block-helper"></i> 重置 </a>
    </form>
</div>
<div class="card-body">
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th class="text-center">
                    <label class="lyear-checkbox checkbox-primary">
                        <input type="checkbox" id="check-all"><span></span>
                    </label>
                </th>
                <th class="text-center"> Id </th>
                <th class="text-center"> 管理员 </th>
                <th class="text-center"> 请求地址 </th>
                <th class="text-center"> 请求方式 </th>
                <th class="text-center hidden-sm hidden-xs"> 描述 </th>
                <th class="text-center hidden-sm hidden-xs"> 登录Ip </th>
                <th class="text-center"> 登录状态 </th>
                <th class="text-center hidden-sm hidden-xs hidden-md"> 登录时间 </th>
                <th class="text-center"> 操作 </th>
            </tr>
            </thead>
            <tbody>
            {if !empty($list) && $list->total()}
            {foreach $list as $key => $item}
            <tr id="id_{$item->log_id}" name="{$item->log_id}">
                <td class="text-center">
                    <label class="lyear-checkbox checkbox-primary">
                        <input type="checkbox" name="log_id[]" value="{$item->log_id}"><span></span>
                    </label>
                </td>
                <td class="text-center"> <a href="javascript:;">{$item->log_id}</a> </td>
                <td class="text-center"> {$item->admin->admin_name ?? ''} </td>
                <td class="text-center"> {$item->log_action} </td>
                <td class="text-center"> {$item->log_method} </td>
                <td class="text-center hidden-sm hidden-xs"> {$item->description} </td>
                <td class="text-center hidden-sm hidden-xs"> {$item->created_ip} </td>
                <td class="text-center">
                    {switch $item->log_status|intval }
                    {case 1}
                    <span class="label label-success"> 登录成功 </span>
                    {/case}
                    {default /}
                    <span class="label label-danger"> 登录失败 </span>
                    {/switch}
                </td>
                <td class="text-center hidden-sm hidden-xs hidden-md">
                    {:date('Y-m-d H:i', $item->created_time)}
                </td>
                <td class="text-center">
                    <a class="btn btn-xs btn-danger" title="删除登录日志" onclick="delOperation({$item->log_id}, '{:url(\'delete\')}')">
                        <i class="icon-trash bigger-120"></i> 删除
                    </a>
                </td>
            </tr>
            {/foreach}
            {else/}
            <tr class="text-center">
                <td colspan="100"> 暂无数据！ </td>
            </tr>
            {/if}
            </tbody>
        </table>
    </div>
    {if !empty($list) && $list->total()}
        <hr>
        <div id="pageList" class="float-right">
            {$list|raw}
        </div>
        <div class="clearfix"></div>
    {/if}
</div>
{/block}

{block name="script-src"}
{/block}

{block name="script"}
<script type="text/javascript">

</script>
{/block}